package com.woniuxy.controller;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.woniuxy.commons.exception.GuidanceException;
import com.woniuxy.commons.exception.MaterialException;
import com.woniuxy.commons.utile.BeanCopyUtil;
import com.woniuxy.commons.utile.Result;
import com.woniuxy.controller.dto.RepairMaterialGetDto;
import com.woniuxy.controller.form.RepairMaterialForm;
import com.woniuxy.dao.model.RepairAttachment;
import com.woniuxy.dao.model.RepairGuidance2;
import com.woniuxy.dao.model.RepairMaterial;
import com.woniuxy.service.RepairAttachmentService;
import com.woniuxy.service.RepairMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 维修用料表 前端控制器
 * </p>
 *
 * @author Keep it simple
 * @since 2022-06-28
 */
@RestController
@RequestMapping("/repairMaterial")
@Api(tags = "材料管理")
public class RepairMaterialController {

    @Resource
    private RepairMaterialService repairMaterialService;


    @PostMapping("/addMaterial")
    @ApiOperation("新增维修材料")
    private Result addMaterial(@Valid @RequestBody RepairMaterialForm repairMaterialForm) throws MessagingException {
        repairMaterialService.addMaterial(repairMaterialForm);
        return Result.instance().setCode(200).setMessage("新增成功");
    }

    @GetMapping("/getRepairMaterial")
    @ApiOperation("通过订单id获取材料信息")
    @ApiImplicitParam(name = "repairnum" , value = "订单id" ,type = "String")
    public Result getRepairMaterial(String repairnum){
        List<RepairMaterialGetDto> repairMaterial = repairMaterialService.getRepairMaterial(repairnum);
        return Result.instance().setData(repairMaterial);
    }
}

